/**
 * @param {number} num
 * @return {number}
 */
 var countEven = function(num) {
  let cnt = 0
  for(let i = 2; i<=num; i++){
    if(check(i)){
      cnt++
    }
  }
  return cnt
  function check(n) {
    const arr = String(n).split('').map(v => Number(v))
    let total = arr.reduce((pre,cur) => pre+cur, 0)
    return total % 2 === 0
  }
};